/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 * \file
 * \brief MaCI Text Main Frame header
 * \author Matthieu Myrsky <matthieu.myrsky@tkk.fi>
 * \author wxFormBuilder (Autogenerated base code)
 *
 * $Id: MaCI_Text_MaCITextFrame.h,v 1.1 2009-07-20 15:21:08 morsko Exp $
 *
 */
#ifndef __MaCI_Text_MaCITextFrame__
#define __MaCI_Text_MaCITextFrame__

/**
@file
Subclass of MaCITextFrame, which is generated by wxFormBuilder.
*/

#include "MaCI_Text_GUI.h"
#include "ownutils.h"
#include "Component.hpp"
#include "TextClient.hpp"
/** Implementing MaCITextFrame */

// Custom events.
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EVENT_TYPE(MY_EVENT_MESSAGEFROMSERVER,-1)
DECLARE_EVENT_TYPE(MY_EVENT_TEXTFROMSERVER,-1)
END_DECLARE_EVENT_TYPES();
class MaCI_Text_MaCITextFrame : public MaCITextFrame,
                                public Gimbo::CComponent,
                                public MaCI::Text::CTextClientCallback
{
 DECLARE_EVENT_TABLE();
 protected:
  // Handlers for MaCITextFrame events.
  void OnSendClick( wxCommandEvent& event );
  void OnClearTextClick( wxCommandEvent& event );
  //Gimbo
  void OnServiceAssignment(const Gimbo::TServiceAssignmentList &aServiceList);  

  void OnMessageFromServer(wxCommandEvent &aEvent); 
  void OnTextEventFromServer(wxCommandEvent &aEvent);
  //TextClient callback
  void OnTextFromServer(std::string &aText, 
                        const unsigned int aDataSequence,
                        MaCI::Text::CTextClient &aTextClient);

  void OnTextReplyFromServer(std::string &aText, 
                             const unsigned int aDataSequence,
                             MaCI::Text::CTextClient &aTextClient);
 public:
  /** Constructor */
  MaCI_Text_MaCITextFrame( wxWindow* parent );
  virtual ~MaCI_Text_MaCITextFrame();

  bool Initialize(gimi::GIMI *aGimiPtr, int aGimboID, int aReportID);
  void Deinitialize(void);
 private:
  void UpdateServiceList(wxCommandEvent &aEvent);
  void DisconnectServices(void);
  bool ConnectServices(void);
  gimi::GIMI *iGIMIPtr; 
  Gimbo::TServiceAssignmentList iServiceList;
  std::vector<MaCI::Text::CTextClient *> iTextClientArray;

};

#endif // __MaCI_Text_MaCITextFrame__
